import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        hasView: false,
        view: null,
        // apiUrl: "/arcgis_js_api/library/4.12",
        apiUrl: "https://js.arcgis.com/4.12",
    },

    getters: {
        getApiOption(state) {
            return {
                url: `${state.apiUrl}/init.js`
            };
        },

        getApiCssUrl(state) {
            return `${state.apiUrl}/esri/css/main.css`;
        },
    },

    mutations: {
        _setView(state, view) {
            state.view = view;
            state.hasView = true;
        }
    },

    actions: {
        setView(context, view = null) {
            context.commit("_setView", view);
        }
    }
})
